#ifndef REFLEX_AUX_H
#define REFLEX_AUX_H

#include <stdint.h>
#include <string>
#include <ostream>
#include "ns3/core-module.h"
#include "ns3/simulator-module.h"
#include "ns3/node-module.h"

 
typedef std::vector<NetDeviceContainer> NetDevices;
typedef std::vector<NetDeviceContainer>::iterator NetDevicesIterator;

void assign_network( Ipv4AddressHelper *ipv4, NetDevices *netdevices )
{
  NetDevicesIterator iter;
  for (iter=netdevices->begin(); iter != netdevices->end(); iter++) {
    ipv4->Assign (*iter);
    ipv4->NewNetwork();
  }                               
}

void printIPs(NodeContainer nodes)
{
  Ipv4Address loopback("127.0.0.1");

  NodeContainer::Iterator iter;

  for (iter = nodes.Begin(); iter != nodes.End(); iter++) {
    Ptr<Node> node = (*iter);
    Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>();
    NS_ASSERT(ipv4 != 0);
                       
    for (uint32_t index = 0; index < ipv4->GetNInterfaces(); index++) {
      Ipv4InterfaceAddress ipv4Address = ipv4->GetAddress(index,0);

      if (ipv4Address.GetLocal() != loopback) {
        std::cout << " node " << node->GetId()<<":"<< index << " ip " << ipv4Address.GetLocal() << " mask " << ipv4Address.GetMask() << std::endl;
      }
      // end iterating over interfaces
    }
  // end iterate over nodes
  }     
}

#endif /* REFLEX_AUX_H */
